﻿#define _CRT_SECURE_NO_WARNINGS 1
int compare_int(const void* p1, const void* p2)
{
    return *(int*)p1 - *(int*)p2;
}
int* findErrorNums(int* nums, int numsSize, int* returnSize)
{
    int* arr = (int*)malloc(sizeof(int) * 2);
    if (arr == NULL)
    {
        perror("malloc fail");
        exit(1);
    }
    *returnSize = 2;
    qsort(nums, numsSize, sizeof(int), compare_int);
    int prev = 0;
    for (int i = 0; i < numsSize; ++i)
    {
        int cur = nums[i];
        if (nums[i] == prev)
        {
            arr[0] = nums[i];
        }
        if (nums[i] - 1 > prev)
        {
            arr[1] = prev + 1;
        }
        prev = cur;
    }
    if (nums[numsSize - 1] != numsSize)
    {
        arr[1] = numsSize;
    }
    return arr;
}








